//
//  GRXSlideView.m
//  1-MushroomStreet-自定义tabbar
//
//  Created by xmg on 15/12/15.
//  Copyright © 2015年 grx. All rights reserved.
//

#import "GRXSlideView.h"

@interface GRXSlideView ()

/**用来保存外界传进来的顶部视图*/
@property (nonatomic, weak) UIView *headerView;


@end

@implementation GRXSlideView

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    NSLog(@"点击了slide");
}


/**
 * 把外界的顶部视图传进来,以获取最合适事件点击view
 */
- (void)deliverHeaderView:(UIView *)headerView{
    _headerView = headerView;
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
    [super hitTest:point withEvent:event];
    
    //把当前点转到红色view上
    CGPoint headerViewPoint  = [self convertPoint:point toView:self.headerView];
    
    //判断触摸点在不在自己身上
    if ([self.headerView pointInside:headerViewPoint withEvent:event]) {
        
        //如过点在红色view上,就调用红的view的hitTest方法
        return [self.headerView hitTest:headerViewPoint withEvent:event];
    }else {
        //调用系统方法,返回view
        return [super hitTest:point withEvent:event];
    }
}


@end
